package com.cci.kangdao.controller;

import com.cci.kangdao.service.CommonQuestionTService;
import com.cci.kangdao.service.CompanyTService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 常见问题controller
 *
 */
@Controller
public class CommonQuestionTController {
	
	private Logger log = Logger.getLogger(this.getClass().getName());
	
	@Resource
	private CommonQuestionTService commonQuestionTService;
	/**
	 * 获取所有常见问题类型集合
	 * @return
	 */
	@RequestMapping("/getCommonQuestionTypeList.aspx")
	public ModelAndView getCommonQuestionTypeList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return commonQuestionTService.getCommonQuestionTypeList(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}

	/**
	 * 根据常见问题分类获取常见问题详情集合
	 * @return
	 */
	@RequestMapping("/getCommonQuestionDetailList.aspx")
	public ModelAndView getCommonQuestionDetailList(HttpServletRequest request,
												  HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return commonQuestionTService.getCommonQuestionDetailList(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}
	
	
}
